// 引入自己封装的ajax名为request函数
import request from "@/utils/request"


// 登录请求
export const checkLogin = (data) => {
    // 发送ajax请求
    return request({
        method: 'post',
        url: '/users/checkLogin',
        data,
    })
}


// 添加账户请求
export const addAccount = (data) => {
    // 发送ajax请求
    return request({
        method: 'post',
        url: '/users/add',
        data,
    })
}


// 获取账号列表
export const getAccountList = (params) => {
    return request({
        method: 'get',
        url: '/users/list',
        params
    })
}


// 修改密码
export const modifyPwd = (data) => {
    // 发送ajax请求
    return request({
        method: 'post',
        url: '/users/editpwd',
        data,
    })
}


// 检查旧密码是否正确
export const checkOldPwd = (params) => {
    return request({
        method: 'get',
        url: '/users/checkoldpwd',
        params
    })
}


// 获取个人中心信息
export const personalData = () => {
    return request({
        method: 'get',
        url: '/users/info',
    })
}


// 修改账号
export const editAccount = (data) => {
    // 发送ajax请求
    return request({
        method: 'post',
        url: '/users/edit',
        data,
    })
}


// 删除账号
export const deleteAccount = (id) => {
    return request({
        method: 'get',
        url: '/users/del',
        params: {
            id
        }
    })
}

// 批量删除
export const batchDelete = (ids) => {
    return request({
        method: 'get',
        url: '/users/batchdel',
        params: {
            ids
        }
    })
}


// 修改头像
export const editAvatar = (imgUrl) => {
    return request({
        method: 'get',
        url: '/users/avataredit',
        params: {
            imgUrl
        }
    })
}

